package com.example.take_out_file.handle;

import com.example.take_out_file.common.Result;
import com.example.take_out_file.exceptions.BusinessException;
import com.example.take_out_file.exceptions.enumetation.ResponseEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description:none
 * @Author:yyyyys、
 * @Date:2024/6/29 2:11
 * @Version:1.0
 **/

@RestControllerAdvice
public class BaseExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result<Object> exceptionHandler(Exception e){
        return Result.error(ResponseEnum.UNKNOWN_ERROR);
    }

    @ExceptionHandler(BusinessException.class)
    public Result<Object> businessException(BusinessException e){
        return Result.error(e.getResponseEnum());
    }
}
